package main

import "fmt"

func main() {
	// 数组分重新赋值，修改底层数组，上面数组不变3
	a1 := [...]int{1,2,3,4}

	s1 := a1
	s3 := a1[:]    //这样赋值会使得s3 和底层a1由指针关系，公用用一个内存空间
	a1[0] = 1000
	fmt.Printf("a1=%v s1=%v", a1, s1)
	fmt.Printf("s3=%v", s3)
	// result a1=[1000 2 3 4] s1=[1 2 3 4]

	// 切片
	b1 := make([]int, 32)
	b1 = append(b1, 1,2,4,5,6)
	s2 := b1
	b1[0] = 2000
	fmt.Printf("b1=%v s2=%v", b1, s2)
	fmt.Println(cap(b1), cap(s2))
	// result b1=[2000 2 3 4] s2=[2000 2 3 4]
}